﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OASys.Entity;
using OASys.Biz.SPBiz;
using OASys.Web.Base;

namespace OASys.Web.Models
{
	public class ModelHomeIndex
	{

	}


	public class ModelHomeMain : BaseModel
	{
		private BizUPPermissionNotice bizUPPermissionNotice;
		public Guid? Level1
		{
			get;
			set;
		}

		public IList<UPPermissionNotice> GridDataSources
		{
			get;
			set;
		}


		public void RetriveData()
		{
			GridDataSources = bizUPPermissionNotice.Invoke(new UPPermissionNoticeParameter()
			{
				departmentid = SessionManager.CurrentSysUser.DepartmentID.Value,
				userid = SessionManager.CurrentSysUser.ID
			});

			var level2 = SessionManager.CurrentSysUserMenus.Where(x => x.ParentID == Level1).Select(x => x.ID).ToList();
			var level3 = SessionManager.CurrentSysUserMenus.Where(x => x.ParentID != null && level2.Contains(x.ParentID.Value)).Select(x=>x.ID).ToList();
			GridDataSources = GridDataSources.Where(x => level3.Contains(x.MenuID.Value)).ToList();
		}


	}

}